let express = require('express')
let bodyParser = require('body-parser')
let app = express()

//配置body-parser
// 只要加上这个配置，则在req请求对象上会多出来一个属性：body
// 因此可以直接通过req.body来获取表单post请求体数据
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());

app.all('/server-fetch',function (request, response) {
    //设置响应头  设置允许跨域
    response.setHeader('Access-Control-Allow-Origin', '*');
    response.setHeader('Access-Control-Allow-Headers', '*');
    let result = {
        name: request.body.name,
        status: request.body.status,
        saas: 'daa'
    }
    let resultStr = JSON.stringify(result)
    response.send(resultStr);
})


app.listen('8000',function () {
    console.log('启动中')
})